M = 30; N = 1e6;
x_u = rand(M, N);
x_n = sum(x_u); % суммируем столбцы
[h, x] = hist(x_n, 30);
inte = sum(h) * (x(2) - x(1)); p = h / inte;
figure(1); plot(x, p,'r','LineWidth', 5);
hold on; bar(x, p); hold off 
xlabel('X'); ylabel('P(X)');
x_n = (x_n - M/2) / sqrt(M/12);
[h, x] = hist(x_n, 30);
inte = sum(h) * (x(2) - x(1)); p = h / inte;
figure(2); plot(x, p,'r','LineWidth', 5);
hold on; 
bar(x, p); hold off
xlabel('X'); ylabel('P(X)');
x_n = 3*x_n + 9;
[h, x] = hist(x_n, 30);
inte = sum(h) * (x(2) - x(1)); p = h / inte;
figure(3); plot(x, p,'r','LineWidth', 5);
hold on; 
bar(x, p); hold off
xlabel('X'); ylabel('P(X)');